perm filename EAUX3B.2[EAL,HE]1 blob
sn#676490 filedate 1982-09-27 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00008 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 {$NOMAIN Editor: More aux routines }
C00024 00003 { Externally defined routines from elsewhere: }
C00027 00004 (* aux routine: varDefine *)
C00032 00005 (* routines for breakpoints: setBpt,clrBpt,clrAllBpts,setTBpt,stepStmnt,clrTBpts *)
C00041 00006 (* debugging routines: tracePdb, trace *)
C00046 00007 (* redrawDisplay *)
C00047 00008 (* collectStmnt *)
C00050 ENDMK
C⊗;
{$NOMAIN Editor: More aux routines }
const
(* Constants from EDIT *)
maxLines = 28; (* smaller on the 11 than on the 10 *)
maxPPLines = 18;
maxBpts = 25;
maxTBpts = 20; (* max could be exceeded by huge case stmnt *)
listinglength = 2000; (* Length of Listingarray *)
(* Random type declarations for OMSI/SAIL compatibility *)
type
byte = 0..255; (* doesn't really belong here, but... *)
ascii = char;
atext = text;
{ Define all the pointer types here }
strngp = ↑strng;
vectorp = ↑vector;
statementp = ↑statement;
varidefp = ↑varidef;
nodep = ↑node;
identp = ↑ident;
tokenp = ↑token;
reswordp = ↑resword;
pdbp = ↑pdb;
envheaderp = ↑envheader;
enventryp = ↑enventry;
environp = ↑environment;
cmoncbp = ↑cmoncb;
linerecp = ↑linerec;
cursorpp = ↑cursorp; {Ron's style, not mine}
(* This one is used whenever a pointer is needed for which the *)
(* definition is missing from this file; naturally, all *)
(* pointers use the same space *)
dump = ↑integer;
(* datatype definitions *)
datatypes = (pconstype, varitype, svaltype, vectype, rottype, transtype,
frametype, eventtype, strngtype, labeltype, proctype, arraytype,
reftype, valtype, cmontype, nulltype, undeftype,
dimensiontype, mactype, macargtype, freevartype);
scalar = real;
u = (used,free);
vector = record case u of
used: (refcnt: integer; val: array [1..3] of real);
free: (next: vectorp);
end;
cstring = packed array [1..10] of ascii;
c4str = packed array [1..4] of ascii;
c5str = packed array [1..5] of ascii;
c20str = packed array [1..20] of ascii;
linestr = packed array [1..130] of ascii;
strng = record
next: strngp;
ch: cstring;
end;
(* statement definitions *)
stmntypes = (progtype, blocktype, coblocktype, endtype, coendtype,
fortype, iftype, whiletype, untiltype, casetype,
calltype, returntype,
printtype, prompttype, pausetype, aborttype, assigntype,
signaltype, waittype, enabletype, disabletype, cmtype,
affixtype, unfixtype,
movetype, operatetype, opentype, closetype, centertype,
stoptype, retrytype,
requiretype, definetype, macrotype, commenttype, dimdeftype,
setbasetype, wristtype, tovaltype, declaretype, emptytype);
(* more??? *)
statement = packed record
next, last: statementp; (* ↑ to lexical tokens? *)
stlab: varidefp;
exprs: nodep; (* any expressions used by this statement *)
nlines: integer;
bpt: boolean;
case stype: stmntypes of
progtype: (pcode: statementp; errors: integer);
blocktype,
declaretype,
endtype,
coendtype: (bcode, bparent: statementp; blkid: identp;
level, numvars: 0..255; variables: varidefp);
coblocktype: (threads: nodep; nthreads: integer; cblkid: identp);
assigntype: (what, aval: nodep);
fortype: (forvar, initial, step, final: nodep; fbody: statementp);
untiltype: (cond: nodep; body: statementp);
casetype: (index: nodep; range, ncases: integer; caselist: nodep);
iftype: (icond: nodep; thn, els: statementp);
cmtype: (oncond: nodep; conclusion: statementp;
deferCm, exprCm: boolean; cdef: varidefp);
end;
(* auxiliary definitions: variable, etc. *)
varidef = packed record
next,dnext: varidefp;
name: identp;
level: 0..255; (* environment level *)
offset: 0..255; (* environment offset *)
dtype: varidefp; (* to hold the dimension info *)
tbits: 0..15; (* special type bits: array = 1, proc = 2, ref = 4 & ? *)
dbits: 0..15; (* for use by debugger/interpreter *)
case vtype: datatypes of
arraytype: (a: nodep);
proctype: (p: nodep);
labeltype,
cmontype: (s: statementp);
mactype: (mdef: statementp);
macargtype: (marg: tokenp);
pconstype: (c: nodep);
dimensiontype: (dim: nodep);
end;
(* definition of the ubiquitous NODE record *)
nodetypes = (exprnode, leafnode, listnode, clistnode, colistnode, forvalnode,
deprnode, viaptnode, apprnode, destnode, durnode,
sfacnode, wobblenode, swtnode, nullingnode, wristnode, cwnode,
arrivalnode, departingnode,
ffnode, forcenode, stiffnode, gathernode, cmonnode, errornode,
calcnode, arraydefnode, bnddefnode, bndvalnode,
waitlistnode, procdefnode, tlistnode, dimnode, commentnode);
exprtypes = ( svalop, (* scalar operators *)
sltop, sleop, seqop, sgeop, sgtop, sneop, (* relations *)
notop, orop, xorop, andop, eqvop, (* logical *)
saddop, ssubop, smulop, sdivop, snegop, sabsop, (* scalar ops *)
sexpop, maxop, minop, intop, idivop, modop,
sqrtop, logop, expop, timeop, (* functions *)
sinop, cosop, tanop, asinop, acosop, atan2op, (* trig *)
vdotop, vmagnop, tmagnop,
vecop, (* vector operators *)
vmakeop, unitvop, vaddop, vsubop, crossvop, vnegop,
svmulop, vsmulop, vsdivop, tvmulop, wrtop,
tposop, taxisop,
transop, (* trans operators *)
tmakeop, torientop, ttmulop, tvaddop, tvsubop, tinvrtop,
vsaxwrop, constrop, ftofop, deproachop, fmakeop, vmkfrcop,
ioop, (* i/o operators *)
queryop, inscalarop,
specop, (* special operators *)
arefop, callop, grinchop, macroop, vmop, adcop, dacop,
badop,
addop, subop, negop, mulop, divop, absop); (* for parsing *)
leaftypes = pconstype..strngtype;
reltypes = sltop..sgtop;
forcetypes = (force,absforce,torque,abstorque,angvelocity);
node = record
next: nodep;
case ntype: nodetypes of
exprnode: (op: exprtypes; arg1, arg2, arg3: nodep; elength: integer);
leafnode: (case ltype: leaftypes of
varitype: (vari: varidefp; vid: identp);
pconstype: (cname: varidefp; pcval: nodep);
svaltype: (s: scalar; wid: integer);
vectype: (v: vectorp);
transtype: (t: dump);
strngtype: (length: integer; str: strngp) ); (* also used by commentnodes *)
clistnode: (cval: integer; stmnt: statementp; clast: nodep);
colistnode: (prev: nodep; cstmnt: statementp);
errornode: (eexpr: nodep);
bnddefnode: (lower, upper: nodep);
waitlistnode: (who: pdbp; when: integer);
procdefnode:(ptype: datatypes; level: 0..255;
pname, paramlist: varidefp; body: statementp);
end;
(* records for parser: ident, token, resword *)
ident = record
next: identp;
length: integer;
name: strngp;
predefined: varidefp;
end;
tokentypes = (reswdtype, identtype, constype, comnttype, delimtype, labeldeftype,
macpartype);
constypes = svaltype..strngtype;
reswdtypes = (stmnttype, filtype, clsetype, decltype, optype, edittype);
filtypes = (abouttype,alongtype,attype,bytype,defertype,dotype,elsetype,
errmodestype,fromtype,handtype,intype,nonrigidlytype,rigidlytype,
sourcefiletype,steptype,thentype,totype,untltype,viatype,
withtype,worldtype,zeroedtype,oftype,wheretype,nowaittype,
ontype,offtype,ppsizetype,collecttype,alltype,lextype);
clsetypes = (approachtype,arrivaltype,departuretype,departingtype,durationtype,
errortype,forcetype,forceframetype,forcewristtype,gathertype,
nildeproachtype,nonullingtype,nullingtype,stiffnesstype,
torquetype,velocitytype,wobbletype,
cwtype,ccwtype,stopwaittimetype,angularvelocitytype,
fxtype,fytype,fztype,mxtype,mytype,mztype,
t1type,t2type,t3type,t4type,t5type,t6type,tbltype);
edittypes = (getcmd,savecmd,insertcmd,renamecmd,startcmd,gocmd,proceedcmd,
stepcmd,sstepcmd,nstepcmd,gstepcmd,executecmd,setcmd,tracecmd,
breakcmd,unbreakcmd,tbreakcmd,definecmd,markcmd,unmarkcmd,
popcmd);
token = record
next: tokenp;
case ttype: tokentypes of
constype: (cons: nodep);
comnttype: (len: integer; str: strngp);
delimtype: (ch: ascii);
reswdtype: (case rtype: reswdtypes of
stmnttype: (stmnt: stmntypes);
filtype: (filler: filtypes);
clsetype: (clause: clsetypes);
decltype: (decl: datatypes);
optype: (op: exprtypes);
edittype: (ed: edittypes) );
identtype: (id: identp);
labeldeftype: (lab: varidefp);
macpartype: (mpar: varidefp);
end;
resword = record
next: reswordp;
length: integer;
name: strngp;
case rtype: reswdtypes of
stmnttype: (stmnt: stmntypes);
filtype: (filler: filtypes);
clsetype: (clause: clsetypes);
decltype: (decl: datatypes);
optype: (op: exprtypes);
edittype: (ed: edittypes);
end;
(* process descriptor blocks & environment record definitions *)
queuetypes = (nullqueue,nowrunning,runqueue,inputqueue,eventqueue,sleepqueue,
forcewait,devicewait,joinwait,proccall);
pdb = packed record
nextpdb,next: pdbp; (* for list of all/active pdb's *)
level: 0..255; (* lexical level *)
mode: 0..255; (* expression/statement/sub-statement *)
priority: 0..255;
status: queuetypes; (* what are we doing *)
env: envheaderp;
spc: statementp; (* current statement *)
epc: nodep; (* current expression (if any) *)
sp: nodep; (* intermediate value stack *)
cm: cmoncbp; (* if we're a cmon point to our definition *)
mech: dump; (* current device being used *)
linenum: integer; (* used by editor/debugger *)
case procp: boolean of (* true if we're a procedure *)
true: (opdb: pdbp; (* pdb to restore when procedure exits *)
pdef: nodep); (* procedure definition node *)
false: (evt: dump; (* event to signal when process goes away *)
sdef: statementp); (* first statement where process was defined *)
end;
envheader = packed record
parent: envheaderp;
env: array [0..4] of environp;
varcnt: 0..255; (* # of variables in use ??? *)
case procp: boolean of (* true if we're a procedure *)
true: (proc: nodep);
false:(block: statementp);
end;
enventry = record
case etype: datatypes of
svaltype: (s: scalar);
vectype: (v: vectorp);
transtype: (t: dump);
frametype: (f: dump);
eventtype: (evt: dump);
strngtype: (length: integer; str: strngp);
cmontype: (c: cmoncbp);
proctype: (p: nodep; penv: envheaderp);
reftype: (r: enventryp);
arraytype: (a: envheaderp; bnds: nodep);
end;
environment = record
next: environp;
vals: array [0..9] of enventryp;
end;
cmoncb = record
running, enabled: boolean; (* cmon's status *)
cmon: statementp;
pdb: pdbp;
evt: dump;
fbits: integer; (* bits for force sensing *)
oldcmon: cmoncbp; (* for debugger *)
end;
(* print related records: *)
cursorp = record
cline,ind: integer;
case stmntp: boolean of
true: (st: statementp);
false: (nd: nodep);
end;
linerec = record
next: linerecp;
start,length: integer
end;
listingarray = packed array [0..listinglength] of ascii;
(* Global variables *)
var
(* From ALMAIN *)
b:boolean;
ch:ascii;
ltime: real;
(* From PARSE *)
reswords: array [0..26] of reswordp;
idents: array [0..26] of identp;
macrostack: array [1..10] of tokenp;
curmacstack: array [1..10] of varidefp;
macrodepth: integer;
curchar, maxchar, curline: integer;
curBlock,newDeclarations: statementp;
curProc: varidefp;
pnode: nodep;
nodim, distancedim, timedim, angledim,
forcedim, torquedim, veldim, angveldim: varidefp;
fvstiffdim, mvstiffdim: nodep;
(* filedepth: integer;
curpage: integer;
sysVars,unVars: varidefp;
errcount: integer;
outerBlock: statementp;
curVariable: varidefp;
curMotion: statementp;
endOk,coendOk: integer;
moveLevel: integer;
curErrhandler, curCmon: statementp; *)
d1: array[1..13] of dump;
endOfLine, backup, expandmacros, flushcomments, dimCheck: boolean;
(* semiseen, shownline: boolean;
eofError: boolean;
inMove,inCoblock: boolean; *)
d2,d3,d4,d5,d6: boolean;
curtoken: token;
file1,file2,file3,file4,file5: atext;
line: linestr;
(* From INTERP *)
curInt, activeInts, readQueue, allPdbs: pdbp;
curEnv, sysEnv: envheaderp;
clkQueue: nodep;
allEvents: dump;
STLevel: integer;
etime: integer;
curtime: integer;
stime: integer;
msg: dump;
inputp: integer;
debugLevel: integer;
tSingleThreadMode: boolean;
resched, running, escapeI, singleThreadMode: boolean;
msgp: boolean; (* flag set if any messages pending *)
inputReady: boolean;
inputLine: array [1..20] of ascii;
(* From EDIT *)
lines: array [1..maxLines] of linerecp;
ppLines: array [1..maxPPLines] of linerecp;
marks: array [1..20] of integer;
cursorStack: array [1..15] of cursorp;
bpts: array [1..maxBpts] of statementp;
tbpts: array [1..maxTBpts] of statementp;
debugPdbs: array [0..10] of pdbp;
screenheight,dispHeight: integer;
ppBufp,oppBufp,ppOffset,ppSize,nmarks: integer;
lbufp,cursor,ocur,cursorLine,fieldnum,lineNum,findLine,pcLine: integer;
firstDline,topDline,botDline,firstLine,lastLine: integer;
freeLines,oldLines: linerecp;
findStmnt: statementp;
nbpts,ntbpts: integer;
eCurInt: pdbp;
dProg: statementp;
smartTerminal: boolean;
setUp,setExpr,setCursor,dontPrint,outFilep,newVarOk,collect: boolean;
eBackup: boolean;
eSingleThreadMode: boolean;
listing: packed array [0..listinglength] of ascii;
lbuf: array [1..160] of ascii;
ppBuf: array [1..100] of ascii;
outFile: atext;
eCurToken: token;
(* Various device & variable pointers *)
speedfactor: enventryp;
barm: dump;
(* Various constant pointers *)
xhat,yhat,zhat,nilvect: vectorp;
niltrans: dump;
bpark, ypark, gpark, rpark: dump; (* arm park positions *)
{ Externally defined routines from elsewhere: }
(* From ALLOC *)
function newNode: nodep; external;
function newStatement: statementp; external;
(* From PAUX2 *)
function evalOrder(what,last: nodep; pcons: boolean): nodep; external;
(* From EAUX1A *)
procedure out1Line(line,start,length: integer); external;
procedure clearLine(i: integer); external;
procedure borderLines; external;
procedure adjustDisplay; external;
function eVarLookup(id: identp): varidefp; external;
(* From IAUX2A *)
procedure getVal (level, offset: byte); external;
(* From EAUX2C *)
procedure displayLines(var pfrom: integer); external;
procedure insertLines(start,number,coff: integer); external;
(* From ETOKEN *)
procedure eGetToken; external;
procedure eGetDelim(char: ascii); external;
(* From EPUTST *)
procedure putstmnt(s: statementp; indent, plevel: integer); external;
(* From PP *)
procedure ppLine; external;
procedure ppOutNow; external;
procedure ppChar(ch: ascii); external;
procedure pp5(ch: c5str; length: integer); external;
procedure pp10(ch: cstring; length: integer); external;
procedure pp10L(ch: cstring; length: integer); external;
procedure pp20(ch: c20str; length: integer); external;
procedure pp20L(ch: c20str; length: integer); external;
procedure ppInt(i: integer); external;
procedure ppReal(r: real); external;
procedure ppStrng(length: integer; s: strngp); external;
procedure ppDtype(d: datatypes); external;
procedure ppDelChar; external;
(* From DISP *)
procedure showCursor(line,col: integer); external;
procedure outLine(line,col,start,length: integer); external;
(* aux routine: varDefine *)
procedure varDefine; external;
procedure varDefine;
var vp: varidefp; n,np: nodep; s: statementp; b: boolean; i: integer;
pold: pdbp;
function pop: nodep; (* Copied from IAUX1 *)
begin
pop := curInt↑.sp;
if curInt↑.sp = nil then
begin (* **** error - stack underflow **** *)
pp20L('Value Stack Underflo',20); ppChar('w'); ppLine;
(* code to show where error occurred & to maybe recover??? *)
end
else curInt↑.sp := curInt↑.sp↑.next;
end;
procedure prntStrng(length: integer; s: strngp); (* Copied from IAUX2 *)
begin
ppStrng(length,s);
ppOutNow;
end;
begin
b := true;
if (cursorStack[cursor].stmntp) and
(cursorStack[cursor-1].stmntp) then
if cursorStack[cursor-1].st↑.stype = blocktype then
begin
b := false;
eGetToken;
with eCurToken do
while ttype = identtype do
begin
vp := eVarLookup(id); (* look up the variable *)
if vp <> nil then
begin
np := newNode;
with np↑ do
begin
ntype := leafnode;
ltype := varitype;
vari := vp;
vid := id;
end;
pold := curInt;
curInt := eCurInt; (* so we use right process to access var *)
if vp↑.tbits = 1 then
begin (* it's an array variable *)
(* *** read in subscripts *** *)
(* *** push subscripts onto stack *** *)
(* *** change np node to an arefop *** *)
pp20L('Can''t handle arrays ',20); pp5('yet ',3); ppLine;
end;
getVal(vp↑.level,vp↑.offset); (* get its current value *)
n := pop;
curInt := pold; (* restore current process *)
s := newStatement;
with s↑ do (* make up a new assignment stmnt *)
begin
stype := assigntype;
what := np;
aval := n;
(*** * if vector then should append dimension info, but... *** *)
with n↑ do
if (ltype = vectype) or (ltype = transtype) then
v↑.refcnt := v↑.refcnt + 1; (* so it doesn't disappear *)
exprs := aval;
aval↑.next := nil;
end;
with cursorStack[cursor] do
begin
s↑.next := st; (* splice in the assignment statement *)
s↑.last := st↑.last;
st↑.last := s;
with s↑.last↑ do
if next = st then next := s else bcode := s;
i := cline;
cline := cline + 1; (* update where cursor now is *)
cursorLine := cline;
end;
insertLines(i,1,1); (* make space in display for it *)
firstLine := i;
lastLine := i;
setCursor := false;
curLine := 0;
putStmnt(dProg,0,99); (* write & display new line *)
adjustDisplay; (* make sure cursor is on screen *)
displayLines(lineNum);
end
else
begin
pp20L('Undefined variable: ',20);
prntStrng(id↑.length,id↑.name);
pp20(' will ignore it. ',16); ppLine;
end;
eGetToken;
if not endOfLine then
begin eBackup := true; eGetDelim(',') end;
eGetToken; (* get next variable name *)
end;
showCursor(cursorLine-topDline-firstDline+2,1);
end;
if b then
begin
pp20('Can''t insert an assi',20); pp20('gnment here - Sorry.',20);
ppLine;
end;
end;
(* routines for breakpoints: setBpt,clrBpt,clrAllBpts,setTBpt,stepStmnt,clrTBpts *)
procedure setBpt(st: statementp); external;
procedure setBpt;
var i: integer;
begin
if not st↑.bpt then (* don't do anything if bpt already set *)
begin
nbpts := nbpts + 1;
if nbpts > maxBpts then
begin
pp20L('Gack - too many BPTs',20); ppLine;
bpts[1]↑.bpt := false; (* flush oldest bpt *)
for i := 2 to maxBpts do bpts[i-1] := bpts[i];
nbpts := maxBpts;
end;
bpts[nbpts] := st;
st↑.bpt := true;
end;
end;
procedure clrBpt(st: statementp); external; (* Also appears in FREE *)
procedure clrBpt;
var i: integer; b: boolean;
begin
if st↑.bpt then (* don't do anything if bpt not set *)
begin
b := true;
for i := 1 to nbpts do
if b then b := bpts[i] <> st (* first find statement in list *)
else bpts[i-1] := bpts[i]; (* then compact the list *)
if not b then
begin
st↑.bpt := false; (* clear it only if we set it *)
bpts[nbpts] := nil;
nbpts := nbpts - 1;
end;
(* else wonder how the bpt got set? *)
end;
end;
procedure clrAllBpts; external;
procedure clrAllBpts;
var i: integer;
begin
for i := 1 to nbpts do
begin bpts[i]↑.bpt := false; bpts[i] := nil end;
nbpts := 0;
end;
procedure setTBpt(st: statementp); external;
procedure setTBpt;
var i: integer;
begin
with st↑ do
if not bpt then (* don't do anything if bpt already set *)
begin
ntbpts := ntbpts + 1;
if ntbpts > maxTBpts then
begin
pp20L('Gack - too many temp',20); pp10('orary BPTs',10); ppLine;
tbpts[1]↑.bpt := false; (* flush oldest bpt *)
for i := 2 to maxTBpts do tbpts[i-1] := tbpts[i];
ntbpts := maxTBpts;
end;
tbpts[ntbpts] := st;
bpt := true;
end;
end;
procedure stepStmnt(bpttype: integer); external;
procedure stepStmnt;
var i: integer; st: statementp; n: nodep;
procedure setTBptsAux(st: statementp);
begin
if st <> nil then
with st↑ do
if stype = endtype then
begin
if bparent↑.stype = fortype then setTBpt(bparent↑.fbody)
else if bparent↑.stype <> cmtype then setTBpt(bparent)
else setTBpt(bparent↑.conclusion); (* do we really want this??? *)
if bparent↑.next <> nil then setTBptsAux(bparent↑.next);
if bparent↑.stype = blocktype then setTBpt(st);
end
else if stype = coendtype then setTBpt(st↑.bparent↑.next)
else if (stype = returntype) and (next = nil) and eCurInt↑.procp then
begin (* appended return *)
setTBptsAux(eCurInt↑.opdb↑.spc↑.next) (* stop after we get back *)
end
else setTBpt(st);
end;
begin (* stepStmnt *)
(* bpttype = 1 single step descending to lower levels + procedure calls
(* = 2 " " " " " " + no procedure calls
(* = 3 " " but stay at current level
(* = 4 step up to next higher lexical level *)
st := eCurInt↑.spc; (* find where we're stepping from *)
with st↑ do
if stype = progtype then st := pcode;
if bpttype <= 3 then
begin
if bpttype = 1 then
begin (* look if any procedure calls in st↑.exprs *)
n := st↑.exprs;
while n <> nil do
with n↑ do
if (ntype = exprnode) and (op = callop) then
begin (* set a bpt at first statement in procedure *)
setTBpt(arg1↑.vari↑.p↑.body);
n := nil;
end
else n := next;
end;
if bpttype <= 2 then
with st↑ do (* look if can descend down a level *)
case stype of
blocktype: setTBpt(bcode);
coblocktype:setTBpt(threads↑.cstmnt); (* always goes there first *)
fortype: setTBpt(fbody);
whiletype,
untiltype: setTBpt(body);
casetype: begin
n := caselist;
while n <> nil do begin setTBpt(n↑.stmnt); n := n↑.next end;
end;
iftype: begin
setTBpt(thn);
if els <> nil then setTBpt(els);
end;
cmtype: setTBpt(conclusion);
(* *** what about cmon's & then code in motion statements ??? *** *)
otherwise {do nothing};
end;
if (st↑.stype = returntype) and eCurInt↑.procp then
begin (* figure out where procedure returns to *)
if bpttype = 1 then
begin (* check if expression will call another proc *)
n := eCurInt↑.epc;
while n <> nil do
with n↑ do
if (ntype = exprnode) and (op = callop) then
begin (* set a bpt at first statement in procedure *)
setTBpt(arg1↑.vari↑.p↑.body);
n := nil;
end
else n := next;
end;
setTBptsAux(eCurInt↑.opdb↑.spc↑.next) (* stop after we get back *)
end
else
begin
setTBptsAux(st↑.next); (* just stop at next stmnt *)
setTBptsAux(st); (* in case we're the body of a loop *)
end;
end
else
begin (* deal with going up a level *)
while st <> nil do
if (st↑.stype<>coendtype) and (st↑.stype<>endtype) then st := st↑.next
else
with st↑.bparent↑ do
if stype = progtype then st := nil
else if (stype = blocktype) or (stype = fortype) then
begin setTBptsAux(next); st := nil end
else begin setTBptsAux(st); st := nil end;
if eCurInt↑.procp then (* we may exit the procedure *)
setTBptsAux(eCurInt↑.opdb↑.spc↑.next); (* so stop after we get back *)
end;
end (* stepStmnt *);
procedure clrTBpts; external; (* Also appears in EDEBUG *)
procedure clrTBpts;
var i: integer;
begin
for i := 1 to ntbpts do
begin tbpts[i]↑.bpt := false; tbpts[i] := nil end;
ntbpts := 0;
end;
(* debugging routines: tracePdb, trace *)
procedure tracePdb(p: pdbp); external;
procedure tracePdb;
var n,np: nodep;
begin
if p = curInt then pp10('(active) ',9);
with p↑ do
case status of
nowrunning,
runqueue: pp10('running ',8);
inputqueue: pp20('input wait ',11);
eventqueue: pp20('event wait ',11);
forcewait: pp20('force sensing wait ',19);
sleepqueue: pp10('sleeping ',9);
joinwait: pp20('process join wait ',18);
devicewait: pp20('motion wait ',12);
otherwise {do nothing};
end;
while p↑.procp do
begin
with p↑.pdef↑.pname↑.name↑ do
ppStrng(length,name); (* tell procedure name *)
pp5(': ',2);
ppInt(p↑.linenum);
if ppbufp > 60 then ppLine else pp5(' ',3);
p := p↑.opdb;
end;
if p↑.cm <> nil then pp10('(cmon)/ ',7) (* ??? tell anything else ??? *)
else if p↑.linenum = 0 then pp10('(tty:)/***',10)
else pp10('(main)/ ',7);
if p↑.linenum > 0 then ppInt(p↑.linenum);
ppLine;
end;
procedure trace(all: boolean); external;
procedure trace;
var i,j: integer;
procedure traceAux(p: pdbp; plev: integer);
begin
if p <> nil then
with p↑ do
begin
traceAux(p↑.nextpdb,plev); (* do the oldest first *)
if (status <> nullqueue) and (status <> proccall) and
(priority >= 10 * plev) then
begin
pp10L('Process ',8); ppInt(i); ppChar(' ');
tracePdb(p);
i := i + 1;
end;
end;
end;
begin
if all then
begin
i := 1;
for j := debugLevel downto 0 do
begin
if j > 0 then
begin
pp20L('Immediate execution ',20); pp10('level: ',7);
ppInt(j); ppLine;
end
else if debugLevel > 0 then
begin pp20L('Program execution ',17); ppLine end;
if j > 0 then traceAux(debugPdbs[j],j);
traceAux(allPdbs,j);
end;
end
else
begin
tracePdb(eCurInt);
end;
end;
(* redrawDisplay *)
procedure redrawDisplay; external;
procedure redrawDisplay;
var i: integer;
begin
for i := 1 to dispHeight do
if lines[firstDline+i-1] <> nil then
with lines[firstDline+i-1]↑ do
out1Line(i,start,length)
else clearLine(i);
borderLines;
for i := 1 to ppSize do
if ppLines[i] <> nil then
with ppLines[i]↑ do (* redraw pp too *)
outLine(dispHeight+1+i,1,start,length)
else clearLine(dispHeight+1+i);
oppBufp := 0; ppOutNow; (* last line too *)
showCursor(cursorLine-topDline-firstDline+2,1);
end;
(* collectStmnt *)
procedure collectStmnt(s: statementp); external;
procedure collectStmnt;
var i: integer;
begin
if collect then (* if collecting add it to program *)
with cursorStack[cursor] do
if stmntp and cursorStack[cursor-1].stmntp and
(cursorStack[cursor-1].st↑.stype = blocktype) then
begin
s↑.bpt := false;
s↑.next := st; (* splice in the statement *)
s↑.last := st↑.last;
st↑.last := s;
with s↑.last↑ do
if next = st then next := s else bcode := s;
setCursor := false;
setUp := true; (* need to format new stmnt *)
curLine := 1;
putStmnt(s,ind,99); (* set it up *)
setUp := false;
i := cline;
cline := cline + s↑.nlines; (* update where cursor now is *)
cursorLine := cline;
insertLines(i,s↑.nlines,1); (* make space in display for it *)
firstLine := i;
lastLine := cline - 1;
setCursor := false;
curLine := 0;
putStmnt(dProg,0,99); (* write & display new line(s) *)
adjustDisplay; (* make sure cursor is on screen *)
displayLines(lineNum);
end
else
begin
collect := false;
pp20('Can''t insert here. T',20); pp20('urning collect OFF. ',19);
ppLine;
end;
end;